<!doctype html>
<html>
<head>
<meta charset="utf-8"/>
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-touch-fullscreen" content="yes">
<title>top menu 测试</title>
<link href="../assets/menu.css" rel="stylesheet"/>
<link href="../assets/menuitem.css" rel="stylesheet"/>
<link href="../assets/submenu.css" rel="stylesheet"/>
<style>
    #menuTest {
        width: 300px;
    }

    .horizonal .ks-menuitem {
        float: left;
        width: 100px;
        overflow: hidden;
    }

    .horizonal {
        zoom: 1;
        overflow: hidden;
    }
</style>
</head>
<body>
<h1 style="text-align: center;">
    顶部导航菜单
</h1>
<div id="context" style="width: 500px;margin:50px auto;">

</div>
<script src="/kissy/build/seed.js"></script>
<script src="/kissy/src/package.js"></script>
<script>


    KISSY.use("menu,separator", function (S, Menu,Separator) {
        var context = S.all("#context");

        var sb = new Menu.PopupMenu({
            // boolean，是否鼠标脱离菜单后自动隐藏
            autoHideOnMouseLeave:true,
            align:{
                offset:[-1, 4],
                points:['bl', 'tl']
            }
        });

        sb.addChild(new Menu.Item({

            content:"submenuitem1"}));
        sb.addChild(new Menu.Item({

            content:"submenuitem2"}));

        sb.addChild(new Separator());

        var sb2 = new Menu.PopupMenu({

            // boolean，是否鼠标脱离菜单后自动隐藏
            autoHideOnMouseLeave:true,
            children:[
                new Menu.Item({

                    content:"submenuitem141"})
            ],
            // bug elStyle 无效
            elStyle:{
                color:"red"
            }
        });
        sb2.addChild(new Menu.Item({

            content:"submenuitem22"}));

        var b2 = new Menu.SubMenu({

            content:"sub-sub-menu",
            menu:sb2
        });

        sb.addChild(b2);

        var b = new Menu.SubMenu({
            content:"submenu",
            menu:sb
        });

        var menu = new Menu({

            width:440,
            render:'#context',
            elCls:"horizonal",
            children:[b, new Menu.Item({

                content:"alone"})]
        });

        menu.render();

        menu.on("click", function (e) {
            alert(e.target.get("content"));
        });
    });

</script>
</body>
</html>